package com.tcgroup.phone.base_core.widget.dialog.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.tcgroup.phone.base_core.R;
import com.tcgroup.phone.base_core.widget.dialog.model.Dirc;

import java.util.ArrayList;

/**
 * 作者: wangfei
 * 创建时期: 2020/5/9.
 * 包名: com.cusc.zhcd.Basic.dialog.adapter
 * 类名: ZhongHeCheDui
 */
public class BottomRvAdapter extends RecyclerView.Adapter<BottomRvAdapter.BottomHolder> {

    public Context mContext;
    public ArrayList<Dirc> mList = new ArrayList<>();


    public BottomRvAdapter(Context context) {
        mContext = context;
    }


    @NonNull
    @Override
    public BottomHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.core_dialog_bottom_adapter_item,parent,false);
        BottomHolder bottomHolder = new BottomHolder(view);
        return bottomHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull BottomHolder holder, int position) {
        holder.content.setText(mList.get(position).getItemName());
        holder.relativeLayout.setOnClickListener(v -> {
        });
    }

    public void setData(ArrayList<Dirc> list){
        mList.clear();
        mList.addAll(list);
        notifyDataSetChanged();
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class BottomHolder extends RecyclerView.ViewHolder{
        TextView content;
        RelativeLayout relativeLayout;
        public BottomHolder(@NonNull View itemView) {
            super(itemView);
            content = itemView.findViewById(R.id.content);
            relativeLayout = (RelativeLayout) itemView;
        }
    }

    public interface ChooseItemClick{
        void itemClick(Dirc dirc);
    }

}
